#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int N=105;

int dp[N][N],n,v[N],w[N],m,k[N];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d%d%d",&v[i],&w[i],&k[i]);
	
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) 
		{
			dp[i][j]=dp[i-1][j];
			for (int cnt=1;cnt<=k[i];cnt++) 
			if (cnt*v[i]<=j)
			dp[i][j]=max(dp[i][j],dp[i-1][j-cnt*v[i]]+w[i]*cnt); 
		}
	
	int ans=0;
	for (int i=0;i<=m;i++) ans=max(ans,dp[n][i]);
	printf("%d\n",ans);
	return 0;
}
